package minh.bac.wcbrazil2014.news;

import minh.bac.wcbrazil2014.R;
import android.annotation.SuppressLint;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.webkit.WebChromeClient;
import android.webkit.WebView;
import android.webkit.WebViewClient;

public class NewsFragment extends Fragment {
	private String url;
	WebView webView;
	public static String KEY_URL = "KEYURL";
	public static NewsFragment newInstace(String urlWeb)
	{
		NewsFragment fragment = new NewsFragment();
		Bundle bundle = new Bundle();
		bundle.putString(KEY_URL, urlWeb);
		fragment.setArguments(bundle);
		return fragment;
	}
	@SuppressLint("SetJavaScriptEnabled")
	@Override
	public View onCreateView(LayoutInflater inflater, ViewGroup container,
			Bundle savedInstanceState) {
		// TODO Auto-generated method stub'
		View rootView = inflater.inflate(R.layout.news_layout, container, false);
		url = getArguments().getString(KEY_URL);
		Log.d("WEBView", url);
		
		webView =  (WebView) rootView.findViewById(R.id.webView1);
		//webView = new WebView(getActivity());
		webView.setWebViewClient(new WebViewClient());		
		webView.getSettings().setBuiltInZoomControls(true);
		webView.getSettings().setJavaScriptEnabled(true);
		return rootView;
	}
	@Override
	public void onResume() {
		// TODO Auto-generated method stub		
		super.onResume();
		
		webView.loadUrl(url);
	}
	public String getUrl() {
		return url;
	}
	public void setUrl(String url) {
		this.url = url;
	}

}
